package cn.biplam.front.component.view.systemManage.sysprivi.role.manage.navi;

import cn.biplam.common.ajxcode.SystemCode.RoleSelectNaviCode;
import cn.biplam.common.client.DataFilter;
import cn.biplam.common.struc.SysStruc.RoleIndexStruc;
import cn.biplam.common.struc.SysStruc.UserRoleStruc;
import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.common.wrapper.UserInfo;
import cn.biplam.front.component.data.tree.treebase.TreeCallBackNew;
import cn.biplam.front.component.data.tree.treebase.TreeDcIndex;
import cn.biplam.front.component.view.tree.TreeBase;
import cn.biplam.front.component.view.tree.TreeView;

/**
 *  角色选择树
 * @author XiaoRuxing Nov 2, 20094:35:59 PM
 * @version 1.0
 */
public class RoleSelect extends TreeView{

	public final static String cId=RoleSelectNaviCode.cId;
	/** 树展开动作ID */
	public static final String Expand = RoleSelectNaviCode.Navi;
	
	/** 过滤条件操作码 */
	private String filterOptId;
	/** 过滤条件 */
	private String userId;
	
	public RoleSelect() {
		super(Expand);
	}

	/**
	 *  设置过滤条件操作码
	 * @param filterOptId 过滤操作码
	 * @param userId      节点过滤条件
	 */
	public void setFilterOperator(String filterOptId,String userId){
		this.filterOptId = filterOptId;
		this.userId = userId;
	}
	
	/**
	 * 设置树的数据信息
	 * @param treeBase			树的基础VC
	 * @param mUser				页面请求的用户类(由调用树的vc传入)
	 * @throws ErrorMessage
	 */
	@Override
	protected void setTree(TreeBase treeBase, UserInfo mUser)
			throws ErrorMessage {
		/**树的callback设置*/
		TreeCallBackNew callback = new TreeCallBackNew();
		
		//创建树DC
		TreeDcIndex curDc = new TreeDcIndex(mUser,//用户信息
				RoleIndexStruc.Table_Name,   //角色索引表名
				null,
				"2");
		
		//设置节点过滤器
		String roleFilterName = ".role_filter_user";
		if(params!=null){
			this.userId = params.getByKey(roleFilterName);
		}
		treeBase.setCustomerParam(roleFilterName,this.userId);
		//设置过滤条件
		DataFilter filter = new DataFilter();
		filter.put(UserRoleStruc.USER_ID, 
				this.userId //当前角色ID
		);
		curDc.setNodeFilter(filter);
		//设置过滤操作
		if(this.filterOptId!=null){
			curDc.setFilterOperatorId(this.filterOptId);
		}
		
		//设置树DC
		treeBase.putTreeDc(1, 
				curDc,
				callback);
		//设置图片
		treeBase.setShowCheckBox(true);//设置显示选择框
		treeBase.setRightMenu(false);//设置不显示右键
	}
}